In [1]:
import sympy
What is the area of a circle of radius 3?
In [3]:
A='9*pi'
print('The answer is: %0.2f' % sympy.sympify(A).evalf())
What is the antiderivative of $x^2+4x$? (write as a function of the indeterminate x
)
In [19]:
A='2*x^2+x^3/3'
X=sympy.Symbol('x')
correct_answer = X**3/3+2*X**2
correct_answer
Out[19]:
In [20]:
print('My answer is: %s' % A)
print('The assignment answer is %s' % repr(correct_answer))
print(correct_answer == sympy.sympify(A))
It also means you don't have to escape anything because it doesn't do python evals
In [21]:
sympy.sympify('os.system("ls")')
In [ ]: